//
//  XcodeCleanBarVC.swift
//  ZJTools
//
//  Created by 万孟超 on 2023/11/25.
//

import Cocoa
import SnapKit

class XcodeCleanBarVC: BaseVC {
    
    lazy var cleanButton: NSButton = {
        let button = NSButton()
        button.bezelStyle = .inline
        button.wantsLayer = true
        button.target = self
        button.action = #selector(startClean)
        button.layer?.cornerRadius = 20
        button.image = NSImage(named: "xcodeClean")?.image(color: .randomColor())
        return button
    }()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do view setup here.
    }
    
    @objc func startClean() {
        cleanButton.isEnabled = false
        cleanButton.addAnimatedGradientBorder()
        XcodeCleanManager.shared.onekeyCleanXcode {
            Async(.main) {
                self.cleanButton.stopAnimation()
                self.cleanButton.isEnabled = true
            }
        }
    }
    
    override func installSubViews() {
        view.addSubview(cleanButton)
    }
    
    override func installViewsContains() {
        cleanButton.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.size.equalTo(CGSize(width: 40, height: 40))
        }
    }
}
